{
                                                                                                          {
 FUNCTIONS INCLUDED:

-   getPowVal
     Type: GET
       Description: Get the pow of an integer value.

-   getIntUnits
     Type: GET
       Description: Get all units of an integer value.

-   getIntUnit
     Type: GET
       Description: Get a specific unit of an integer value (from right).

-   convIntToStr
     Type: SET
       Description: Convert an integer value into a string.
}

:getPowVal
{
 Parameters:
   Passed:
     0@ - base
     1@ - exponent
   Result:
     2@ - integer/float

 Example:
   0AB1: call_scm_func @getPowVal 2 num 2 exp 3 store_to 0@ 
}
0085: 2@ = 0@ 
if 
 1@ > 0 
then
 for 3@ = 1 to 1@ 
   if 
     3@ > 1 
   then
     006A: 2@ *= 0@ 
   end
 end
else
 if 
   1@ < 0 
 then
   0093: 2@ = integer 2@ to_float
   0093: 0@ = integer 0@ to_float
   for 3@ = -1 to 1@ 
     if 
       3@ < -1 
     then
       006B: 2@ *= 0@ 
     end
   end
   4@ = 1.0 
   0073: 4@ /= 2@ 
   0087: 2@ = 4@ 
 else
   2@ = 1 
 end
end
0AB2: ret 1 2@ 

:getIntUnits
{
 Parameters:
   Passed:
     0@ - number
   Result:
     1@ - units -> 0 to 10

 Example:
   0AB1: call_scm_func @getIntUnits 1 num 125 store_to 0@ 
}
1@ = 0 
0095: make 0@ absolute_integer
if 
 0@ <> 0 
then
 while 0@ > 0 
   0@ /= 10 
   1@ += 1 
 end
else
 1@ = 1 
end
0AB2: ret 1 1@ 

:getIntUnit
{
 Parameters:
   Passed:
     0@ - number
     1@ - unit position -> 0 to 10
   Result:
     0@ - unit

 Example:
   0AB1: call_scm_func @getIntUnit 2 num 125 unit 2 store_to 0@ 
}
0095: make 0@ absolute_integer
0AB1: call_scm_func @getIntUnits 1 num 0@ store_to 2@ 
if 
002D:  2@ >= 1@ 
then
 0085: 3@ = 0@ 
 0AB1: call_scm_func @getPowVal 2 num 10 exp 1@ store_to 4@ 
 0072: 3@ /= 4@ 
 006A: 3@ *= 4@ 
 0062: 0@ -= 3@ 
 1@ -= 1 
 0AB1: call_scm_func @getPowVal 2 num 10 exp 1@ store_to 4@ 
 0072: 0@ /= 4@ 
else
 0@ = 0 
end
0AB2: ret 1 0@ 

:convIntToStr
{
 Parameters:
   Passed:
     0@ - number -> -9999999 to 9999999
   Result:
     2@/3@ - string value

 Example:
   0AB1: call_scm_func @convIntToStr 1 num 125 store_to 1@ 2@ 
}
if and
 0@ <=  9999999 
 0@ >= -9999999 
then
 0AB1: call_scm_func @getIntUnits 1 num 0@ store_to 1@ 
 if 
   1@ > 7 
 then
   1@ = 7 
 end
 2@s = '' 
 if 
   0@ < 0 
 then
   2@s = '-' 
 end
 for 4@ = 1@ downto 1 
   0AB1: call_scm_func @getIntUnit 2 num 0@ unit 4@ store_to 5@ 
   5@ += 0x30 
   098B: 2@s = 2@s + 5@s 
 end
end
0AB2: ret 2 2@ 3@

:Pow_integer
{
 Description:     
    Returns base raised to the power of exp. Passed base and expotent should be integer.
 Type: SET

 Parameters:
   Passed:
     0@ - base
     1@ - exponent
   Result:
     0@ - base raised to the power of exp.

 Example:
  0AB1: call_scm_func @Pow_integer 2 base 2 exponent 4 store_to 0@
}
// 0@ - 5
// 1@ - 0
0085: 3@ = 0@ // (int)
2@ = 1

if
0029: 1@ >= 1
then
jump @POW_INT_POSITIVE
else
jump @POW_INT_NEGATIVE
end

:POW_INT_POSITIVE
if
8045: 2@ !== 1@ // (float)
else_jump @POW_INT_RETURN
006A: 3@ *= 0@ // (int)
inc(2@)
jump @POW_INT_POSITIVE

:POW_INT_NEGATIVE
if
8045: 2@ !== 1@ // (float)
else_jump @POW_INT_RETURN
0072: 3@ /= 0@ // (int)
dec(2@)
jump @POW_INT_NEGATIVE

:POW_INT_RETURN
0AB2: ret 1 3@

:Pow_float
{
 Description:     
    Returns base raised to the power of exp. Passed base and expotent should be integer.
 Type: SET

 Parameters:
   Passed:
     0@ - base
     1@ - exponent
   Result:
     0@ - base raised to the power of exp.

 Example:
  0AB1: call_scm_func @Pow_float 2 base 2 exponent 4 store_to 0@
}

0085: 3@ = 0@ // (int)
2@ = 1

if
1@ >= 1
then
jump @POW_FLOAT_POSITIVE
else
jump @POW_FLOAT_NEGATIVE
end

:POW_FLOAT_POSITIVE
if
803B: 2@ !== 1@ // (int)
else_jump @POW_FLOAT_RETURN
006B: 3@ *= 0@ // (float)
Inc(2@)
jump @POW_FLOAT_POSITIVE

:POW_FLOAT_NEGATIVE
if
803B: 2@ !== 1@ // (int)
else_jump @POW_FLOAT_RETURN
0073: 3@ /= 0@ // (float)
Dec(2@)
jump @POW_FLOAT_NEGATIVE

:POW_FLOAT_RETURN
0AB2: ret 1 3@